﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web;

namespace Feelingme.ShareMSDN
{
    /// <summary>
    /// Summary description for ShipProvider
    /// </summary>
    public class ShipProvider : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            var template = context.Application["ship.htm"] as string;

            string pv = context.Request.QueryString["pv"];
            if (pv == null || !pv.Contains(':'))
            {
                return;
            }

            var spv = pv.Split(':');
            if (spv.Length != 3)
            {
                return;
            }


            int familyId = int.Parse(spv[0]);
            int locale = int.Parse(spv[1]);
            int sort = int.Parse(spv[2]);

            string responseHTML = SharedUtil.GetShipsRawHTML(template, familyId, locale, sort);

            context.Response.ContentType = "text/html";
            context.Response.Write(responseHTML);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}